/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
package com.jeesite.modules.biz.service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.jeesite.common.entity.Page;
import com.jeesite.common.service.CrudService;
import com.jeesite.modules.biz.dao.BizGoodsDao;
import com.jeesite.modules.biz.entity.BizGoods;
import com.jeesite.modules.file.utils.FileUploadUtils;

/**
 * 物料表Service
 * @author Lai_Hanzhang
 * @version 2019-03-11
 */
@Service
@Transactional(readOnly=true)
public class BizGoodsService extends CrudService<BizGoodsDao, BizGoods> {
	
	/**
	 * 获取单条数据
	 * @param bizGoods
	 * @return
	 */
	@Override
	public BizGoods get(BizGoods bizGoods) {
		return super.get(bizGoods);
	}
	
	/**
	 * 查询分页数据
	 * @param bizGoods 查询条件
	 * @param bizGoods.page 分页对象
	 * @return
	 */
	@Override
	public Page<BizGoods> findPage(BizGoods bizGoods) {
		return super.findPage(bizGoods);
	}
	
	/**
	 * 查询所有数据
	 * @param bizGoods 查询条件
	 * @return
	 */
	public List<BizGoods> findAlldata(BizGoods bizGoods) {
		return super.findList(bizGoods);
	}
	
	/**
	 * 获取下拉框数据
	 * @param bizGoods 查询条件
	 * @return
	 */
	public List<Map<Object,Object>> getGoodsDown(BizGoods bizGoods) {
		List<Map<Object,Object>> downList = new ArrayList<Map<Object,Object>>();
		List<BizGoods> goodsList = super.findList(bizGoods);
		for (BizGoods model : goodsList){
			Map<Object,Object> map = new HashMap<Object,Object>();
			map.put("dictLabel", model.getGoodsName());
			map.put("dictValue", model.getGoodsId());
			downList.add(map);
		}
		return downList;
	} 
	
	
	
	/**
	 * 保存数据（插入或更新）
	 * @param bizGoods
	 */
	@Override
	@Transactional(readOnly=false)
	public void save(BizGoods bizGoods) {
		super.save(bizGoods);
		// 保存上传图片
		FileUploadUtils.saveFileUpload(bizGoods.getId(), "bizGoods_image");
	}
	
	/**
	 * 更新状态
	 * @param bizGoods
	 */
	@Override
	@Transactional(readOnly=false)
	public void updateStatus(BizGoods bizGoods) {
		super.updateStatus(bizGoods);
	}
	
	/**
	 * 删除数据
	 * @param bizGoods
	 */
	@Override
	@Transactional(readOnly=false)
	public void delete(BizGoods bizGoods) {
		super.delete(bizGoods);
	}
	
}